package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("fos.txt");
   /*     while (true){
            int d=fis.read();
            if (d==-1){
                break;
            }
            System.out.print((char)d);
            fis.close();
        }*/
        int d;
        while ((d=fis.read())!=-1){
            System.out.print((char)d);
        }
        fis.close();
        FileInputStream fis2=new FileInputStream("image.jpg");
        FileOutputStream fos2=new FileOutputStream("image-cp.jpg");
        int d2;
        long start=System.currentTimeMillis();
        while ((d2=fis2.read())!=-1){
            fos2.write(d2);
        }
        long end=System.currentTimeMillis();
        System.out.println("复制完成，耗时"+(end-start)+"毫秒");
        fis2.close();
        fos2.close();


    }
}
